#include <stdio.h>
#include <stdlib.h>
/*int compare(int a[], int size,int remaining){
    int count=0;
    for (int i=0; i<size;i++){
        int num=a[i];
        if (num==remaining){
            count++;
            continue;
        }
        if (num>remaining){continue;}
        if (i==size-1){break;}
        else{
            int *b=a+(i+1);
            int count2=compare(b,size-i-1,remaining-num);
            count+=count2;
        }
    }
    return count; 
}*/
int *a=NULL;
/*
int compare(int n,int remaining){
	if(remaining==0) return 1;		
	if(n<=0) return 0;		 
	return compare(n-1,remaining)+compare(n-1,remaining-a[n-1]);	
}
*/


int compare(int n, int remaining) {
    int dp[n + 1][remaining + 1];
    for (int i = 0; i <= n; i++) {
        for (int j = 0; j <= remaining; j++) {
            if (j == 0) {
                dp[i][j] = 1; // 没有石头时，有一种方式组成重量0
            } else if (i == 0) {
                dp[i][j] = 0; // 没有石头时，不能组成重量j
            } else {
                if (a[i - 1] <= j) {
                    dp[i][j] = dp[i - 1][j] + dp[i - 1][j - a[i - 1]];
                } else {
                    dp[i][j] = dp[i - 1][j];
                }
            }
        }
    }
    return dp[n][remaining];
}




void main(){
    int time=0;
    int n;
    int num=0;
    
    while(scanf("%d",&n)!=EOF){
        if (time==0){num=n;a=(int *)malloc(num*sizeof(int));}
        else{
            a[time-1]=n;
        }
        if (time==num){
            time=0;
            int count=compare(n,40);
            printf("%d",count);
            printf("\n");
            free(a);
            continue;
        }
        time+=1;
    }


}